<?php

namespace App\Validation;

use Phalcon\Validation\Validator\PresenceOf;
use Phalcon\Validation\Validator\Numericality;
use Phalcon\Validation\Validator\InclusionIn;

class HotSearchValidation extends BaseValidation
{
	public function initialize()
    {
		$this->add(
			"name",
			new PresenceOf(
				  [
					  "message" => ":field is required",
					  // "allowEmpty" => true,
				  ]
			)
		);
			
    }

	//验证之前
	public function beforeValidation($data, $entity, $messages)
    {
		$data->name = property_exists($data,'name') ? $data->name : "web";

        return true;
    }
}